package com.das.metrocloud.ssoserver.runner;

import org.springframework.boot.*;
import org.springframework.context.annotation.*;
import com.das.metrocloud.ssoserver.config.*;
import org.springframework.beans.factory.annotation.*;
import com.das.framework.common.jwt.*;
import java.util.*;
import org.slf4j.*;

@Configuration
public class AuthServerRunner implements CommandLineRunner
{
    private static Logger log;
    @Autowired
    private AuthKeyConfig keyConfig;
    
    public void run(final String... args) throws Exception {
        final Map<String, byte[]> keyMap = (Map<String, byte[]>)RsaKeyHelper.generateKey(this.keyConfig.getUserSecret());
        this.keyConfig.setUserPriKey(keyMap.get("pri"));
        this.keyConfig.setUserPubKey(keyMap.get("pub"));
        AuthServerRunner.log.info("Authentication key initialization successfully.");
    }
    
    static {
        AuthServerRunner.log = LoggerFactory.getLogger((Class)AuthServerRunner.class);
    }
}
